import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _dec3, _class, _class2;

/**
 * ModalForm
 * 仅用于密码修改框
 * @date 2018/11/26
 */
import React from 'react';
import { Form, Modal } from 'antd';
import { Bind } from 'lodash-decorators';

function noop() {}

var ModalForm = (_dec = Form.create({
  fieldNameProp: null
}), _dec2 = Bind(), _dec3 = Bind(), _dec(_class = (_class2 = /*#__PURE__*/function (_React$Component) {
  _inherits(ModalForm, _React$Component);

  var _super = _createSuper(ModalForm);

  function ModalForm() {
    _classCallCheck(this, ModalForm);

    return _super.apply(this, arguments);
  }

  _createClass(ModalForm, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          modalProps = _this$props.modalProps,
          _this$props$renderFor = _this$props.renderFormItems,
          renderFormItems = _this$props$renderFor === void 0 ? noop : _this$props$renderFor,
          form = _this$props.form;
      return /*#__PURE__*/React.createElement(Modal, Object.assign({}, modalProps, {
        destroyOnClose: true,
        afterClose: this.cleanForm,
        onOk: this.handleOk
      }), renderFormItems(form));
    }
  }, {
    key: "cleanForm",
    value: function cleanForm() {
      var form = this.props.form;
      form.resetFields();
    }
  }, {
    key: "handleOk",
    value: function handleOk() {
      var _this = this;

      var form = this.props.form;
      form.validateFields(function (err, fieldsValue) {
        if (!err) {
          var onOk = _this.props.onOk;
          onOk(fieldsValue, form);
        }
      });
    }
  }]);

  return ModalForm;
}(React.Component), (_applyDecoratedDescriptor(_class2.prototype, "cleanForm", [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, "cleanForm"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleOk", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "handleOk"), _class2.prototype)), _class2)) || _class);
export { ModalForm as default };